package cn.edu.neusoft.wuguangsheng.flowerimpression.fragment;


import android.app.Fragment;
import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.MeiTuAdapter;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.MeiTuBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.GetMeiTuListModel;

/**
 * A simple {@link Fragment} subclass.
 */
public class MeiTuFragment extends BaseFragment {
    RecyclerView recyclerView;
    private List<MeiTuBean> items;

    @Override
    void initView() {

         recyclerView = view.findViewById(R.id.recyclerView_girls);
        GetMeiTuListModel getMeiTuListModel = new GetMeiTuListModel();

        getMeiTuListModel.getMeiTuList(new ListListener<MeiTuBean>() {
            @Override
            public void onResponse(List<MeiTuBean> list) {

                StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
                recyclerView.setLayoutManager(layoutManager );
                items=list;
                MeiTuAdapter meiTuAdapter=new MeiTuAdapter(getContext(),items,R.layout.meitu_item);
                recyclerView.setAdapter(meiTuAdapter);
                recyclerView.setItemAnimator(new DefaultItemAnimator());
            }

            @Override
            public void onFail(String msg) {
                Toast.makeText(getContext(),"111",Toast.LENGTH_SHORT).show();
            }
        });
    }


    @Override
    void initEvent() {


    }

    @Override
    void initDate() {

    }

    public MeiTuFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_mei_tu);
        return super.onCreateView(inflater,container,savedInstanceState);
    }

}
